#{extends '/include/main.html' /}
<div class="form-page">
	<a href="@@{CoreTableController.list()}" class="form-backto-result-button">返回</a>
	#{if coreTable}
		<form action="@@{CoreTableController.delete()}?x-http-method-override=DELETE" method="POST" class="delete-form">
			<input type="hidden" name="tableId" value="${coreTable.id}" />
			<input type="submit" value="删除" class="form-submit-zone-submit-button"/>
		</form>
	#{/if} 
	<h2 class="form-title">核心表管理</h2>
	#{if coreTable}
		<form action="@@{CoreTableController.update}?x-http-method-override=PUT" method="POST">
		<input type="hidden" name="tableId" value="${coreTable.id}" />
	#{/if} 
	#{else}
		<form action="@@{CoreTableController.save}" method="POST">
	#{/else}
		<table class="form-submit-zone">
			<tbody>
				<tr>
					<th>表名</th>
					<td>
						<input type="text" name="name" value="${(flash.name || flash.name == '') ? flash.name : (coreTable ?.name)}" />
						<div class="error"><span>#{error 'name' /}</span></div>
					</td>
				</tr>
				<tr>
					<th>维护人员</th>
					<td>
						<select name="maintainerId">
							<option value="">请选择</option>
							#{list items : maintainers, as : 'maintainer'}
								<option value="${maintainer.id}" #{if (flash.maintainerId == maintainer.id.toString()) || (flash.maintainerId != '' &&  coreTable && coreTable.maintainer.id == maintainer.id)}selected#{/if}>${maintainer.name}</option>
							#{/list}
						</select>
						<div class="error"><span>#{error 'maintainerId' /}</span></div>
					</td>
				</tr>
				<tr>
					<th>中文描述</th>
					<td>
						<input type="text" value="${coreTable ?.description}" name="description" />
					</td>
				</tr>
				
				<tr>
					<th>提交</th>
					<td>
						<input type="submit" value="提交" class="form-submit-zone-submit-button"/>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</div>